# encoding:utf-8 
import sys


def style(word, prop):
	return '<span style="'+prop+'">'+word+"</span>"

# HTML Dictionaries 
pseudocode = {		"==": style("==", "font-weight: bold;color:white"),
				">": style(">", "font-weight: bold;color:white"),
				"<": style("<", "font-weight: bold;color:white"),
				"او": style("او", "font-weight: bold;color:white"),
				"و": style("و", "font-weight: bold;color:white"),
				"عكس": style("عكس", "font-weight: bold;color:white"),
				"إذا": style("إذا", "color: #7ae234; font-weight: bold"),
				"في": style("في", "color: #7ae234; font-weight: bold"),
				"لكل": style("لكل", "color: #7ae234; font-weight: bold")
}
acli = {}

# Dictionry index
languagedicts = {	"pseudocode": pseudocode,
						"acli": acli}

# Enclosing tags: change if changing color theme
openingtag='<pre style="direction:rtl;text-align:right;background-color:#222222;font-family:monospace;padding:5px;color:#DDDDDD">'
closingtag="</pre>"

## Main program logic starts here
try:
	lookup=languagedicts[sys.argv[1]]
except IndexError:
	sys.stderr.write("Error: No language specified.\n")
	sys.exit(1)
except KeyError:
	sys.stderr.write("Error: Unrecognized language ("+sys.argv[1]+")\n")
	sys.exit(1)

sys.stdout.write(openingtag+"\n")
for i in sys.stdin.readlines():
	for j in i.split(" "):

		#nevermind, fix THIS uglieness
		if (j[-1] == "\n"): 
			a="\n"
			j=j[:-1]
		else: 
			a=" "

		p=""
		for k in j:
			if k == "\t":
				p+=k
			else:
				break
		j=j[len(p):]

		#fix this ugliness
		try:
			j=long(j)
		except ValueError:
			try:
				j=int(j)
			except ValueError:
				try:
					j=float(j)
				except ValueError: pass
		if (isinstance(j, (int, float, long))):
			sys.stdout.write(style(str(j), p+"color: #edd400")+a)
			continue			
		
		try:
			sys.stdout.write(p+lookup[j]+a)
		except KeyError:
			sys.stdout.write(p+j+a)
sys.stdout.write(closingtag)		

